package com.dabbo.starship.cell;

import java.rmi.RemoteException;

import com.dabbo.starship.interfaces.Block;
import com.dabbo.starship.interfaces.Cell;
import com.dabbo.starship.interfaces.ConsoleMode;

public class CellConsole extends CellDefault {

	private static final long serialVersionUID = 3904452850520485161L;

	public CellConsole(Block parent) throws RemoteException {
		super(parent);
		this.activated = false;
		this.consoleMode = ConsoleMode.MODE_UNASSIGNED;
		this.cargoAllowed = false;
		this.cellType = Cell.CELL_CONSOLE;
		this.passable = true;
		this.powerOutput = 0;
	}
	
	@Override
	public void tick() {
		if (damage > 40) {
			Double test = 30 + (Math.random() * 80);
			if (test < damage) {
				this.activated = false;
				this.powerOutput = 0;
			}
		}
	}
	
	@Override
	public void activate() throws RemoteException {
		if (this.getParent().getParent().getPowerOutput() > 0) {
			this.activated = true;
			this.powerOutput = -18;			
		}
	}

	public void deActivate() throws RemoteException {
		if (this.consoleMode == ConsoleMode.MODE_SELECT_MENU) {
			this.consoleMode = ConsoleMode.MODE_UNASSIGNED;
		}
		this.activated = false;
		this.powerOutput = 0;
	}

	
}
